package com.learn.search.controller;

import com.learn.search.service.ICourseService;
import com.learn.eduapi.entity.Course;
import com.learn.eduapi.entity.PageEntity;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@Slf4j
@RestController
public class CourseController {

    @Autowired
    private ICourseService courseService;

    @RequestMapping("search-courses")
    public ResponseEntity<PageEntity<Course>> searchCoursePage(@RequestBody Map<String,String> args){
        log.info("search-courses args:{}",args);
        PageEntity<Course> page = courseService.searchCoursePage(args);
        log.info("search-courses page:{}",page);
        return ResponseEntity.ok(page);
    }
}
